package com.petcare;

import com.bd.PetsModule;
import com.bd.Utilities;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class profilepet extends Activity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.activity_profilepet);
	    
	    final Button button1 = (Button) findViewById(R.id.button1);
        button1.setOnClickListener(new View.OnClickListener() {
            
        	public void onClick(View v) {
            	Intent myIntent = new Intent(profilepet.this, alarms.class);
            	startActivity(myIntent);
            }
        });
        
        final Button button2 = (Button) findViewById(R.id.button2);
        button2.setOnClickListener(new View.OnClickListener() {
            
        	public void onClick(View v) {
            	Intent myIntent = new Intent(profilepet.this, caretips.class);
            	startActivity(myIntent);
            }
        });
	    
	    Bundle bundle = this.getIntent().getExtras();
	    PetsModule myPet = Utilities.datasource.getPet(bundle.getInt("pk")+"");
	   
	    TextView textName = (TextView) findViewById(R.id.textView1);
	    textName.setText(myPet.getName());
	    
	    TextView textAge = (TextView) findViewById(R.id.TextView22);
	    textAge.setText(myPet.getAge()+"");
	    
	    TextView textSpicies = (TextView) findViewById(R.id.textView6);
	    textSpicies.setText(myPet.getSpicies());
	    
	    TextView textFood = (TextView) findViewById(R.id.textView7);
	    textFood.setText(myPet.getFood());
	    
	     
	    
	    Bitmap bitmap;// = BitmapFactory.decodeFile(myPet.getPicture());
	    ImageView picture = (ImageView)findViewById(R.id.imageView1);
	    if(myPet.getPicture().equalsIgnoreCase("")){
    		picture.setImageResource(R.drawable.ic_launcher);
    	}
    	else {
    		bitmap = BitmapFactory.decodeFile(myPet.getPicture());
    		picture.setImageBitmap(bitmap);
    	}
		//picture.setImageBitmap(bitmap);
		
	    System.out.println(myPet.toString());
	
	    // TODO Auto-generated method stub
	}
	
	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}
